package com.kaishengit.service;


import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.kaishengit.core.service.BaseService;
import com.kaishengit.pojo.Employee;
import com.kaishengit.pojo.Product;
import com.kaishengit.pojo.ProductEmployee;


@Service
@Transactional
public class ProductService extends BaseService{
	
	


	public void save(Employee employee) {
		Product product = new Product();
		product.setName(employee.getCompanyname());
		
		getProductDao().save(product);
		
		ProductEmployee pe = new ProductEmployee();
		pe.setEmployee(employee);
		pe.setProduct(product);
		pe.setRole(ADMIN);
		
		getProductEmployeeDao().save(pe);
		
	}

	public Product findNameByEmployeeId(Employee e) {
		return getProductDao().findNameByEmployeeId(e);
	}

	public Product findById(int id) {
		return getProductDao().findById(id);
	}




}
